package com.entity;

import javax.persistence.*;
import java.math.BigDecimal;
import java.sql.Timestamp;

/**
 * Created by Administrator on 2015/7/22.
 */
@Entity
public class House {
    private int houseId;
    private String houseDescription;
    private BigDecimal housePrice;
    private Timestamp housePubdate;
    private Integer houseFloorage;
    private String houseContack;
    private Type type;
    private Street street;
    private User user;

    @Id
    @Column(name = "house_id")
    public int getHouseId() {
        return houseId;
    }

    public void setHouseId(int houseId) {
        this.houseId = houseId;
    }

    @Basic
    @Column(name = "house_description")
    public String getHouseDescription() {
        return houseDescription;
    }

    public void setHouseDescription(String houseDescription) {
        this.houseDescription = houseDescription;
    }

    @Basic
    @Column(name = "house_price")
    public BigDecimal getHousePrice() {
        return housePrice;
    }

    public void setHousePrice(BigDecimal housePrice) {
        this.housePrice = housePrice;
    }

    @Basic
    @Column(name = "house_pubdate")
    public Timestamp getHousePubdate() {
        return housePubdate;
    }

    public void setHousePubdate(Timestamp housePubdate) {
        this.housePubdate = housePubdate;
    }

    @Basic
    @Column(name = "house_floorage")
    public Integer getHouseFloorage() {
        return houseFloorage;
    }

    public void setHouseFloorage(Integer houseFloorage) {
        this.houseFloorage = houseFloorage;
    }

    @Basic
    @Column(name = "house_contack")
    public String getHouseContack() {
        return houseContack;
    }

    public void setHouseContack(String houseContack) {
        this.houseContack = houseContack;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        House house = (House) o;

        if (houseId != house.houseId) return false;
        if (houseDescription != null ? !houseDescription.equals(house.houseDescription) : house.houseDescription != null)
            return false;
        if (housePrice != null ? !housePrice.equals(house.housePrice) : house.housePrice != null) return false;
        if (housePubdate != null ? !housePubdate.equals(house.housePubdate) : house.housePubdate != null) return false;
        if (houseFloorage != null ? !houseFloorage.equals(house.houseFloorage) : house.houseFloorage != null)
            return false;
        if (houseContack != null ? !houseContack.equals(house.houseContack) : house.houseContack != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = houseId;
        result = 31 * result + (houseDescription != null ? houseDescription.hashCode() : 0);
        result = 31 * result + (housePrice != null ? housePrice.hashCode() : 0);
        result = 31 * result + (housePubdate != null ? housePubdate.hashCode() : 0);
        result = 31 * result + (houseFloorage != null ? houseFloorage.hashCode() : 0);
        result = 31 * result + (houseContack != null ? houseContack.hashCode() : 0);
        return result;
    }

    @ManyToOne
    @JoinColumn(name = "type_id", referencedColumnName = "type_id")
    public Type getType() {
        return type;
    }

    public void setType(Type type) {
        this.type = type;
    }

    @ManyToOne
    @JoinColumn(name = "street_id", referencedColumnName = "street_id")
    public Street getStreet() {
        return street;
    }

    public void setStreet(Street street) {
        this.street = street;
    }

    @ManyToOne
    @JoinColumn(name = "user_id", referencedColumnName = "user_id")
    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }
}
